<html>
<head><meta charset="utf-8"><title>Vec::into_raw_parts and *mut T vs NonNull&lt;T&gt; · t-libs · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/index.html">t-libs</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/Vec.3A.3Ainto_raw_parts.20and.20*mut.20T.20vs.20NonNull.3CT.3E.html">Vec::into_raw_parts and *mut T vs NonNull&lt;T&gt;</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="205663183"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/Vec%3A%3Ainto_raw_parts%20and%20%2Amut%20T%20vs%20NonNull%3CT%3E/near/205663183" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Ashley Mannix <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/Vec.3A.3Ainto_raw_parts.20and.20*mut.20T.20vs.20NonNull.3CT.3E.html#205663183">(Aug 01 2020 at 04:12)</a>:</h4>
<p>Hey all <span aria-label="wave" class="emoji emoji-1f44b" role="img" title="wave">:wave:</span> I spent some time thinking about <span class="user-mention" data-user-id="219747">@Simon Sapin</span>’s <a href="https://github.com/rust-lang/rust/issues/65816#issuecomment-546405936">suggestion on the <code>Vec::into_raw_parts</code> tracking issue</a> to return a <code>NonNull&lt;T&gt;</code> instead of a <code>*mut T</code>. I was thinking we could keep our APIs moving forward to more modern approaches without losing symmetry or consistency with existing ones by specifying a set of methods for leaking and working with containers: <a href="https://github.com/KodrAus/rfcs/blob/container-leak/text/0000-container-leak.md">https://github.com/KodrAus/rfcs/blob/container-leak/text/0000-container-leak.md</a></p>



<a name="205663192"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/Vec%3A%3Ainto_raw_parts%20and%20%2Amut%20T%20vs%20NonNull%3CT%3E/near/205663192" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Ashley Mannix <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/Vec.3A.3Ainto_raw_parts.20and.20*mut.20T.20vs.20NonNull.3CT.3E.html#205663192">(Aug 01 2020 at 04:12)</a>:</h4>
<p>What do you all think? It’s _very_ sketchy :slight_smile: I just threw it together now for some feedback before going down the rabbithole properly</p>



<a name="205663276"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/Vec%3A%3Ainto_raw_parts%20and%20%2Amut%20T%20vs%20NonNull%3CT%3E/near/205663276" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Ashley Mannix <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/Vec.3A.3Ainto_raw_parts.20and.20*mut.20T.20vs.20NonNull.3CT.3E.html#205663276">(Aug 01 2020 at 04:15)</a>:</h4>
<p>(deleted)</p>



<a name="205668010"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/Vec%3A%3Ainto_raw_parts%20and%20%2Amut%20T%20vs%20NonNull%3CT%3E/near/205668010" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scottmcm <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/Vec.3A.3Ainto_raw_parts.20and.20*mut.20T.20vs.20NonNull.3CT.3E.html#205668010">(Aug 01 2020 at 06:30)</a>:</h4>
<p>Hmm, is <code>.leak_raw()</code> (rougly) equivalent to <code>.leak().into()</code>, since the <code>&amp;mut</code> can give the <code>NonNull</code> safely?</p>



<a name="205670549"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/Vec%3A%3Ainto_raw_parts%20and%20%2Amut%20T%20vs%20NonNull%3CT%3E/near/205670549" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Ashley Mannix <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/Vec.3A.3Ainto_raw_parts.20and.20*mut.20T.20vs.20NonNull.3CT.3E.html#205670549">(Aug 01 2020 at 08:01)</a>:</h4>
<p><span class="user-mention" data-user-id="125270">@scottmcm</span> It is, yes. It’s just meant to be discoverable and symmetrical with <code>unleak_raw</code> and <code>unleak_raw_parts</code>, which might need a capacity too</p>



<a name="205757043"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/Vec%3A%3Ainto_raw_parts%20and%20%2Amut%20T%20vs%20NonNull%3CT%3E/near/205757043" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Ashley Mannix <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/Vec.3A.3Ainto_raw_parts.20and.20*mut.20T.20vs.20NonNull.3CT.3E.html#205757043">(Aug 03 2020 at 03:30)</a>:</h4>
<p>I think I'll fill the rest of this in, do a dummy implementation and then PR it up</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>